<?php
header("Content-type:text/html; charset=utf-8" );
$conn =mysql_connect('localhost','root','')
or die('数据库无法连接');
mysql_set_charset('utf8');
mysql_select_db('neu-video',$conn)
or die('数据库不存在');
$sql='select * from users';
$result=mysql_query($sql,$conn);//执行sql
/*while ($result &&($row=mysql_fetch_assoc($result))!==FALSE) {
	echo $row['uname'].'<br>';
	# code...
}*/
$users=fetch_array($result);
//var_dump($users);
echo '<table border="1">';
echo '<tr><th>用户编号</th><th>用户名</th><th>密码</th><th>性别</th><th>生日</th><th>爱好</th><th>学历</th><th>介绍</th><th>头像</th></tr>';
foreach ($users as $one ) {
	echo '<tr>';
	echo '<td>'.$one['uid'].'</td>';
	echo '<td>'.$one['uname'].'</td>';
	echo '<td>'.$one['password'].'</td>';
	echo '<td>'.$one['gender'].'</td>';
	echo '<td>'.$one['birthdate'].'</td>';
	echo '<td>'.$one['hobby'].'</td>';
    echo '<td>'.$one['degree'].'</td>';
    echo '<td>'.$one['intro'].'</td>';
    echo '<td>'.$one['pic'].'</td>';
	echo '</tr>';# code...
}
echo '</table>';

$sql='select * from videotype';
$result=mysql_query($sql,$conn);
$videotype = fetch_array($result);
echo '<table border = "1">';
echo '<tr><th>视频类型名</th></tr>';
foreach($videotype as $one )
{
	echo '<tr>';
	echo '<td>'.$one ['tid'].'</td>';
	echo '<td>'.$one ['int'].'</td>';
	echo '</tr>';
}
echo '</table>';

$sql='select * from videos';
$result=mysql_query($sql,$conn);
$videos=fetch_array($result);
echo '<table border="1">';
echo '<tr><th>视频ID</th><th>视频名称</th><th>视频类型</th><th>海报</th><th>内容简介</th><th>添加日期</th><th>上传用户</th><th>点击率</th><th>下载量</th><th>下载地址</th>';
foreach ($videos as $one ) {
	echo '<tr>';
	echo '<td>'.$one['vid'].'</td>';
	echo '<td>'.$one['videoname'].'</td>';
	echo '<td>'.$one['tid'].'</td>';
	echo '<td>'.$one['pic'].'</td>';
	echo '<td>'.$one['intro'].'</td>';
	echo '<td>'.$one['uploaddate'].'</td>';
	echo '<td>'.$one['uploadadmin'].'</td>';
	echo '<td>'.$one['hittimes'].'</td>';
	echo '<td>'.$one['downtimes'].'</td>';
	echo '<td>'.$one['address'].'</td>';
	echo '</tr>';# code...
}

echo '</table>';
function fetch_array($results){
	$arrs=array();
	while ($results &&($row=mysql_fetch_assoc($results))!==FALSE) {
	$arrs[]=$row;
}
	return $arrs;

}

?>
